package com.ruoyi.system.Controller;

import java.util.List;

import com.ruoyi.system.domain.Vo.CmUserHtHty;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CmUserHtclockin;
import com.ruoyi.system.service.ICmUserHtclockinService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 打卡记录统计Controller
 * 
 * @author pop404NotFound
 * @date 2021-11-22
 */
@Controller
@RequestMapping("/CmSystem/CmUserHtclockin")
public class CmUserHtclockinController extends BaseController
{
    private String prefix = "CmSystem/CmUserHtclockin";

    @Autowired
    private ICmUserHtclockinService cmUserHtclockinService;

    @RequiresPermissions("CmSystem:CmUserHtclockin:view")
    @GetMapping()
    public String CmUserHtclockin()
    {
        return prefix + "/CmUserHtclockin";
    }

    /**
     * 查询打卡记录统计列表
     */
    @RequiresPermissions("CmSystem:CmUserHtclockin:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmUserHtclockin cmUserHtclockin)
    {
        startPage();
        List<CmUserHtHty> list = cmUserHtclockinService.selectCmUserHtclockinList(cmUserHtclockin);
        return getDataTable(list);
    }

    /**
     * 导出打卡记录统计列表
     */
    @RequiresPermissions("CmSystem:CmUserHtclockin:export")
    @Log(title = "打卡记录统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmUserHtclockin cmUserHtclockin)
    {
        List<CmUserHtHty> list = cmUserHtclockinService.selectCmUserHtclockinList(cmUserHtclockin);
        ExcelUtil<CmUserHtHty> util = new ExcelUtil<CmUserHtHty>(CmUserHtHty.class);
        return util.exportExcel(list, "打卡记录统计数据");
    }

    /**
     * 新增打卡记录统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存打卡记录统计
     */
    @RequiresPermissions("CmSystem:CmUserHtclockin:add")
    @Log(title = "打卡记录统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmUserHtclockin cmUserHtclockin)
    {
        return toAjax(cmUserHtclockinService.insertCmUserHtclockin(cmUserHtclockin));
    }

    /**
     * 修改打卡记录统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CmUserHtHty cmUserHtHty = cmUserHtclockinService.selectCmUserHtclockinById(id);
        mmap.put("cmUserHtclockin", cmUserHtHty);
        return prefix + "/edit";
    }

    /**
     * 修改保存打卡记录统计
     */
    @RequiresPermissions("CmSystem:CmUserHtclockin:edit")
    @Log(title = "打卡记录统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmUserHtclockin cmUserHtclockin)
    {
        return toAjax(cmUserHtclockinService.updateCmUserHtclockin(cmUserHtclockin));
    }

    /**
     * 删除打卡记录统计
     */
    @RequiresPermissions("CmSystem:CmUserHtclockin:remove")
    @Log(title = "打卡记录统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmUserHtclockinService.deleteCmUserHtclockinByIds(ids));
    }
}
